import 'package:flutter_deer/generated/json/base/json_convert_content.dart';
import 'package:flutter_deer/util/socket/bean/socket_serializable_models.dart';

MdcSetPrcNzlCmdBean $MdcSetPrcNzlCmdBeanFromJson(Map<String, dynamic> json) {
  final MdcSetPrcNzlCmdBean mdcSetPrcNzlCmdBean = MdcSetPrcNzlCmdBean();
  final int? cmdType = jsonConvert.convert<int>(json['cmdType']);
  if (cmdType != null) {
    mdcSetPrcNzlCmdBean.cmdType = cmdType;
  }
  final int? num = jsonConvert.convert<int>(json['num']);
  if (num != null) {
    mdcSetPrcNzlCmdBean.num = num;
  }
  final List<PrcOil>? items = (json['items'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<PrcOil>(e) as PrcOil).toList();
  if (items != null) {
    mdcSetPrcNzlCmdBean.items = items;
  }
  return mdcSetPrcNzlCmdBean;
}

Map<String, dynamic> $MdcSetPrcNzlCmdBeanToJson(MdcSetPrcNzlCmdBean entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['cmdType'] = entity.cmdType;
  data['num'] = entity.num;
  data['items'] = entity.items.map((v) => v.toJson()).toList();
  return data;
}

extension MdcSetPrcNzlCmdBeanExtension on MdcSetPrcNzlCmdBean {
  MdcSetPrcNzlCmdBean copyWith({
    int? cmdType,
    int? num,
    List<PrcOil>? items,
  }) {
    return MdcSetPrcNzlCmdBean()
      ..cmdType = cmdType ?? this.cmdType
      ..num = num ?? this.num
      ..items = items ?? this.items;
  }
}

PrcOil $PrcOilFromJson(Map<String, dynamic> json) {
  final PrcOil prcOil = PrcOil();
  final int? nzl = jsonConvert.convert<int>(json['nzl']);
  if (nzl != null) {
    prcOil.nzl = nzl;
  }
  final int? prc = jsonConvert.convert<int>(json['prc']);
  if (prc != null) {
    prcOil.prc = prc;
  }
  return prcOil;
}

Map<String, dynamic> $PrcOilToJson(PrcOil entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['nzl'] = entity.nzl;
  data['prc'] = entity.prc;
  return data;
}

extension PrcOilExtension on PrcOil {
  PrcOil copyWith({
    int? nzl,
    int? prc,
  }) {
    return PrcOil()
      ..nzl = nzl ?? this.nzl
      ..prc = prc ?? this.prc;
  }
}